function exec(str1,str2)
{
//str1=URLEncoding(str1);
try
{

objXMLHTTP = new ActiveXObject("Microsoft.XMLHTTP"); 
objXMLHTTP.Open ("post", str1, false );
//xmlHttp.open("POST",url,true);  
if(str2)
{ 
 objXMLHTTP.setRequestHeader("Content-Length",str2.length);
  objXMLHTTP.setRequestHeader( " Content-Type " , " application/x-www-form-urlencoded " );   
  objXMLHTTP.send(str2);  
}else
	{
objXMLHTTP.Send() ;
}
var text1=objXMLHTTP.ResponseText;
//alert(text1);
return text1;
}
catch(e1)
{
	//alert(e1);
	return "";
}
}//function
function RS()
{
	this.cmd=function(str1)
	{
		return this.query1("execute",str1);
	}
	this.open=function(str1)
	{
		return this.query1("query",str1);
	}
	this.query=function(str1)
	{
		return this.query1("query",str1);
	}
	this.parse=function(str1)
	{
		//alert(str1);
		try
		{
		this.next_i=0;
		this.rs1=new Array();	
		this.rs_head=null;
		this.rowCount=0;
		this.err="";
		if(str1.length<3000&&str1.split("\t")[0]=="false") {this.err=str1.split("\t")[1]; return false;}
		 this.rs1=str1.split("\r\n");
		this.rs_head=this.rs1[0].split("\t");
		this.rowCount=this.rs1.length-1;
		text1=null;
		return true;
		}
		catch(e1)
		{
			alert(e1);
			//return resql;
		}
	}
	this.query1=function(str0,str1)
	{
		try
		{
		this.next_i=0;
		this.rs1=new Array();	
		this.rs_head=null;
		this.rowCount=0;
		this.err="";

		str1=URLEncoding(str1);
		var text1=exec("/alarmBip/public/xmlsql.jsp","method="+str0+"&sql="+str1);
		if(text1.length<3000&&text1.split("\t")[0]=="false") {this.err=text1.split("\t")[1]; return false;}
	  this.rs1=text1.split("\r\n");
		this.rs_head=this.rs1[0].split("\t");
		this.rowCount=this.rs1.length-1;
		text1=null;
		return true;
		}
		catch(e1)
		{
			alert(e1);
			//return resql;
		}
		
	}
	this.next=function()
	{
		//alert(rs_head);
		
		this.next_i++;
		if(this.next_i>=this.rs1.length) return false;
		return true;
	}
	this.first=function()
	{
		this.next_i=0;
		}
	this.get=function(str1)
	{
		var tmparray=this.rs1[this.next_i].split("\t");
		for(var i=0;i<this.rs_head.length;i++)
		{
			if(this.rs_head[i].toUpperCase()==str1.toUpperCase())
			{
				return tmparray[i];
				}
			}
		return "";
	}
	this.getHead=function(ihead)
	{
		return this.rs_head[ihead];
	}
	this.close=function()
	{
		this.rs1=null;
		this.next_i=0;
		this.rs_head=null;
	}

}
 RS.prototype.next_i=0;
 RS.prototype.rs1=new Array();	
 RS.prototype.rs_head=null;
 RS.prototype.rowCount=0;
 RS.prototype.err="";
